package com.graph;
import com.collection.Bag;
import edu.princeton.cs.algs4.In;

public class Graph {

    private final int V;
    private  int E;

    private Bag<Integer>[] adj;

    Graph(int V) {
        this.V = V;
        adj = (Bag<Integer>[]) new Bag[V];
        for (int i = 0; i < V; i++) {
            adj[i] = new Bag<>();
        }
    }

    Graph (In in) {
        V = in.readInt();
        E = in.readInt();
        adj = (Bag<Integer>[]) new Bag[V];

        for (int i = 0; i < V; i++) {
            adj[i] = new Bag<>();
        }

        for (int i = 0; i < E; i++) {
            int v = in.readInt();
            int w = in.readInt();
            adj[v].add(w);
            adj[w].add(v);
        }
    }

    public void addEdge(int v, int w) {
        adj[v].add(w);
        adj[w].add(v);
        E++;
    }

    public int V() {return V;}
    public int E() {return E;}

    public Iterable<Integer> adj(int v) {
        return adj[v];
    }


    public static void main(String[] args) {

        Graph G = new Graph(new In(args[0]));

    }
}
